#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 2e5 + 5;

int n, m;
int a[N];
struct Block {
  int val;
  list<int> q;
};
list<Block> blks;
void build() {
  rep(i, 1, n) {
    if (i == 1 || a[i] != a[i - 1]) {
      Block b;
      b.val = a[i];
      blks.push_back(b);
    }
    blks.back().q.push_back(i);
  }
}
bool to_del(const Block& b) { return b.q.empty(); }
void check() {
  auto it = blks.begin();
  while (it != blks.end()) {
    auto it2 = next(it);
    while (it2 != blks.end() && (it->val == it2->val || it2->q.empty())) {
      it->q.splice(it->q.end(), it2->q);
      it2 = next(it2);
    }
    it = it2;
  }
  blks.remove_if(to_del);
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  rep(i, 1, n) cin >> a[i];
  build();
  while (blks.size()) {
    for (auto& b : blks) {
      cout << b.q.front() << ' ';
      b.q.pop_front();
    }
    cout << endl;
    check();
  }
  return 0;
}